In [1]:
% matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd


/Users/scott/anaconda/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  return f(*args, **kwds)

Import population data


In [2]:
df = pd.read_csv('./population_data.csv', index_col=0)
df.head()


Out[2]:
state gender age population population_fraction cumulative_fraction
0 Alaska M 18 4856 0.000020 0.000020
1 Alaska M 19 5299 0.000021 0.000041
2 Alaska M 20 6415 0.000026 0.000067
3 Alaska M 21 7023 0.000028 0.000095
4 Alaska M 22 7186 0.000029 0.000124

Plot population by state


In [4]:
df_plt = df.groupby('state')['population_fraction'].sum().reset_index()

import map_util
ax = map_util.usa_state_colormap(dict(zip(df_plt['state'], df_plt['population_fraction'])),
                                 colorbar_title='Population fraction')



In [ ]: